import request from '@/utils/request'

export default {
  selectByPage(page, limit) {
    return request({
      url: `/rbac/role/selectByPage?page=${page}&limit=${limit}`,
      method: 'get'
    })
  },
  deleteById(id) {
    return request({
      url: `/rbac/role/deleteById/${id}`,
      method: 'delete'
    })
  },
  add(role) {
    return request({
      url: `/rbac/role/add`,
      method: 'post',
      data: role // 封装json传到后台@RequestBody
    })
  },
  selectById(id) {
    return request({
      url: `/rbac/role/selectById/${id}`,
      method: 'get'
    })
  },
  update(role) {
    return request({
      url: `/rbac/role/update`,
      method: 'put',
      data: role
    })
  },
  selectAssignedRole(userId) {
    return request({
      url: `/rbac/role/selectAssignedRole/${userId}`,
      method: 'get'
    })
  },
  assignRole(userId, roleIds) {
    return request({
      url: `/rbac/role/assignRole`,
      method: 'post',
      params: {userId, roleIds}
    })
  }

}
